import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup} from '@angular/forms';
import {SharedModule} from '../shared.module';
import {MODAL_WIDTH} from '../../const'
import {TrainingRecord} from '../../types/resp/TrainingRecord';

@Component({
  selector: 'training-record-view',
  imports: [
    SharedModule
  ],
  templateUrl: './training-record-view.component.html',
  standalone: true
})
export class TrainingRecordViewComponent implements OnInit {
  trainingRecordForm!: FormGroup;
  isVisible: boolean = false
  title: string = '培训记录详情'
  modalWidth: string = MODAL_WIDTH

  constructor(
    private fb: FormBuilder
  ) {}

  ngOnInit(): void {
    this.trainingRecordForm = this.fb.group({
      candidateName: [''],
      trainingName: [''],
      trainingDate: [''],
      durationHours: [0],
      provider: [''],
      trainingDescription: [''],
      createTime: [''],
      modifyTime: [''],
    })
  }

  onBack() {
    this.isVisible = false
  }

  display(trainingRecord: TrainingRecord) {
    this.isVisible = true
    this.trainingRecordForm.patchValue(trainingRecord);
    this.trainingRecordForm.disable();
  }
}
